// initial state
const state = {
  user: {
    sexEnum: [{ key: 1, value: '男' }, { key: 2, value: '女' }],
    statusEnum: [{ key: 1, value: '启用' }, { key: 2, value: '禁用' }],
    levelEnum: [{ key: 1, value: '福建省新生儿救护中心' }, { key: 2, value: '福建省生殖医学中心' }, { key: 3, value: '福建省宫颈疾病诊治保健中心' }, { key: 4, value: '福建省产前诊断中心' }, { key: 5, value: '福建省儿童医疗救治中心' }, { key: 6, value: '福建省儿童保健中心' },
      { key: 7, value: '福建省新生儿疾病筛查中心' }, { key: 8, value: '妇科' }, { key: 9, value: '产科' },
      { key: 10, value: '儿科' }, { key: 11, value: '小儿外科' }, { key: 12, value: '麻醉科' },
      { key: 13, value: '手术室' }, { key: 14, value: 'ICU重症监护室' }, { key: 15, value: '急诊科' },
      { key: 16, value: '门诊手术室' }, { key: 17, value: '中医科' }, { key: 18, value: '感染科' },
      { key: 19, value: '妇女保健科' }, { key: 20, value: '甲状腺、乳腺外科' }, { key: 21, value: '整形美容外科' },
      { key: 22, value: '药剂科' }, { key: 23, value: '检验科' }, { key: 24, value: '影像科' },
      { key: 25, value: '超声科' }, { key: 26, value: '病理科' }, { key: 27, value: '输血科' },
      { key: 28, value: '电生理科' }, { key: 29, value: '消毒供应中心' }, { key: 30, value: '医院服务中心' },
      { key: 31, value: '血管外科&介入治疗科' }, { key: 32, value: '办公室' }, { key: 33, value: '党委办公室' },
      { key: 34, value: '人事科' }, { key: 35, value: '保卫科' }, { key: 36, value: '总务科' },
      { key: 37, value: '综合信息科' }, { key: 38, value: '计算机中心' }, { key: 39, value: '医保办' },
      { key: 40, value: '工会' }, { key: 41, value: '老干科' }, { key: 42, value: '组织部' },
      { key: 43, value: '宣传部' }, { key: 44, value: '科教科' }, { key: 45, value: '团委' }],
    roleEnum: [{ key: 1, value: '患者' }, { key: 2, value: '用户' }, { key: 3, value: '部门分管负责人' },
      { key: 4, value: '主任' }, { key: 5, value: '院分管负责人' }, { key: 6, value: '最高管理员' }],
    statusTag: [{ key: 1, value: 'success' }, { key: 2, value: 'danger' }],
    statusBtn: [{ key: 1, value: '禁用' }, { key: 2, value: '启用' }]
  },
  exam: {
    examPaper: {
      paperTypeEnum: [{ key: 1, value: '固定试卷' }, { key: 4, value: '时段试卷' }, { key: 6, value: '任务试卷' }]
    },
    question: {
      typeEnum: [{ key: 1, value: '单选题' }, { key: 2, value: '多选题' }, { key: 3, value: '判断题' }, { key: 4, value: '填空题' }, { key: 5, value: '简答题' }],
      editUrlEnum: [{ key: 1, value: '/exam/question/edit/singleChoice', name: '单选题' },
        { key: 2, value: '/exam/question/edit/multipleChoice', name: '多选题' },
        { key: 3, value: '/exam/question/edit/trueFalse', name: '判断题' },
        { key: 4, value: '/exam/question/edit/gapFilling', name: '填空题' },
        { key: 5, value: '/exam/question/edit/shortAnswer', name: '简答题' }]
    }
  }
}

// getters
const getters = {
  enumFormat: (state) => (arrary, key) => {
    return format(arrary, key)
  }
}

// actions
const actions = {}

// mutations
const mutations = {}

const format = function (array, key) {
  for (let item of array) {
    if (item.key === key) {
      return item.value
    }
  }
  return null
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}
